package com.blakebarrett.windows
{
	import com.blakebarrett.components.Anaglyphizer;
	
	import mx.core.ScrollPolicy;
	import mx.core.Window;
	import mx.events.FlexEvent;
		
	public class StereoPreviewer extends Window
	{
		private var _dataProvider : Array;
		
		public function StereoPreviewer()
		{
			super();
			this.resizable = false;
			this.horizontalScrollPolicy = ScrollPolicy.OFF;
			this.verticalScrollPolicy = ScrollPolicy.OFF;
			this.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
		}
		
		public function set dataProvider ( val : Array ) : void {
			
			if (!val || val.length < 2) return;
			
			_dataProvider = val;
		}
		
		protected function onCreationComplete(e:FlexEvent):void {
			e.currentTarget.removeEventListener(e.type, onCreationComplete);
			var anaglyph : Anaglyphizer = new Anaglyphizer(_dataProvider[0], _dataProvider[1]);
			this.addChild(anaglyph);
			
			this.width = _dataProvider[0].width;
			this.height = _dataProvider[0].height;
		}
	}
}